<template>
	<view class="content">
		<view class="block swiper-block">
			<Swiper1 :styleObj="{width: '100%',height: '400rpx',borderRadius: '0'}" :list="swiperList"></Swiper1>
		</view>
		<view class="block photo-block">
			<view class="price-block">
				<view class="name">{{detail.title?detail.title:''}}</view>
				<view class="sold">评分:{{detail.score?detail.score:''}}</view>
			</view>
		</view>
		<view class="block detail-block">
			<view class="title">简介</view>
			<view class="info">
				<mp-html :content="detail.dscPrice" />
			</view>
		</view>
		<view class="block booking">
			<navigator class="btn1 btn" :url="'/pages/food/list?id='+detail.vid">查看商家</navigator>
		</view>
		<!-- <view class="block booking">
			<view class="btn1 btn" @click="reserve">立即预订</view>
		</view> -->
	</view>
</template>

<script>
	import {
		getMealById,
		postReserve
	} from '@/api/food.js';
	export default {
		data() {
			return {
				detail: {
					discountPrices: 68,
					originalPrice: 146.5,
					sold: 233,
				},
				swiperList: []
			}
		},
		methods: {
			//套餐详情
			getTicketList() {
				let id = this.id
				getMealById({
					id
				}).then((res) => {
					if (res.code == 1) {
						if (res.data != null) {
							this.detail = res.data;
							console.log(this.detail)
							this.swiperList = res.data.viewAtlasList
						}
					} else {
						console.log(res)
					}
				}).catch((res) => {
					console.log(res)
				})
			},
			//预定
			getList() {
				postReserve({
					orderType: 2,
					tid: 0,
					sid: this.id,
					hid: 0,
					count: 0,
					price: this.detail.discountPrice,
					useDate: ''
				}).then((res) => {
					console.log(res)
					if (res.code == 1) {
						uni.showToast({
							title: '预定成功',
							mask: true,
						})
					} else {
						uni.showToast({
							title: '加载失败',
							mask: true,
						})
					}
				}).catch((res) => {
					uni.hideLoading();
					uni.showToast({
						title: '加载失败',
						mask: true,
					})
				})
			},
			reserve() {
				this.getList()
			}
		},
		onLoad(e) {
			console.log(e)
			this.id = e.id
			this.getTicketList()
		},
	}
</script>

<style lang="scss" scoped>
	.content {
		display: flex;
		flex-direction: column;


		.block {
			background: #fff;
		}

		.block.photo-block {
			display: flex;
			flex-direction: column;
			background: #fff;
			padding: 30rpx;
			border-radius: 10rpx;
			box-shadow: 0 0 10px 0px #dadada;

			.price-block {
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: space-between;
				margin-top: 20rpx;

				.name {
					font-weight: bold;
					font-size: 34rpx;
				}

				.sold {
					flex-grow: 0;
					font-size: 28rpx;
					color: $color-secondary-text;
				}
			}
		}

		.block.detail-block {
			display: flex;
			flex-direction: column;
			background: #fff;
			border-radius: 10rpx;
			margin-top: 10rpx;
			padding: 30rpx;
			box-shadow: 0 0 10px 0px #dadada;

			.title {
				font-weight: bold;
				font-size: 34rpx;
			}

			.detail-content {
				font-size: 28rpx;
				padding: 20rpx 0;
			}
		}

		.block.booking {
			width: 100%;
			position: fixed;
			bottom: 0;
			left: 0;
			height: 120rpx;
			display: flex;
			align-items: center;
			justify-content: center;

			.btn {
				margin: 0;
				width: 400rpx;
				height: 80rpx;
				font-size: 28rpx;
			}
		}
	}
</style>
